home *** CD-ROM | disk | FTP | other *** search
/ PC Gamer (Italian) 30 / PC Gamer IT CD 30 1-2.iso / MOTS / GAMEDATA / RESOURCE / JKMRES.GOO / cog_force_grip.cog < prev    next >
Text File  |  1998-02-25  |  8KB  |  322 lines

  1. # Jedi Knight Cog Script
  2. #
  3. # FORCE_GRIP.COG
  4. #
  5. # FORCEPOWER Script - The Grip
  6. #  Dark Side Power
  7. #  Bin 31
  8. #
  9. # This power chokes the enemy in the target cone, slowly causing damage.
  10. #
  11. # [YB]
  12. #
  13. # (C) 1997 LucasArts Entertainment Co. All Rights Reserved
  14.  
  15.  
  16. symbols
  17.  
  18. thing       player                           local
  19. thing       victim                           local
  20. thing       potential                        local
  21.  
  22. flex        cost=50.0                        local
  23. flex        targetcost=5                     local
  24. flex        targetcount=0                    local
  25. flex        mana                             local
  26. flex        dot                              local
  27. flex        maxDot                           local
  28. flex        damage                           local
  29. flex        starthealth                      local
  30. int         rank                             local
  31. int         retval=0                         local
  32.  
  33. sound       gripSound=ForceGrip01.WAV        local
  34.  
  35. int         limit                            local
  36. int         count                            local
  37.  
  38. int         active=0                         local
  39. int         targetting=0                     local
  40.  
  41. int         inbubble=0                       local
  42.  
  43. message     startup
  44. message     activated
  45. message     deactivated
  46. message     pulse
  47. message     timer
  48. message     newplayer
  49. message     killed
  50. message     selected
  51. message     deselected
  52. message     enterbubble
  53. message     exitbubble
  54. message     user0
  55.  
  56. end
  57.  
  58. # ========================================================================================
  59.  
  60. code
  61.  
  62. startup:
  63.    player = GetLocalPlayerThing();
  64.    inbubble = 0;
  65.  
  66.    SetInvActivated(player, 31, 0);
  67.  
  68.    Return;
  69.  
  70. # ........................................................................................
  71.  
  72. activated:
  73.    if(inbubble) Return;
  74.  
  75.    // Cannot use power if blinded
  76.    if(GetActorFlags(player) & 0x800) Return;
  77.  
  78.    if(active) Return;
  79.  
  80.    mana = GetInv(player, 14);
  81.    if(mana >= cost || GetInv(player, 14) >= GetInv(player, 69))
  82.    {
  83.       victim = -1;
  84.       active = 1;
  85.       targetting = 1;
  86.       SetPulse(0.33);
  87.       SetBinWait(player, 31, 1.0);
  88.    }
  89.    Return;
  90.  
  91. # ........................................................................................
  92.  
  93. deactivated:
  94.    // If no victim was found just cleanup and exit
  95.    if((victim == -1) || (GetThingHealth(player) <= 0) || !active || inbubble)
  96.    {
  97.       call stop_power;
  98.       Return;
  99.    }
  100.  
  101.    SetPulse(0);
  102.    jkEndTarget();
  103.    targetting = 0;
  104.  
  105.    mana = GetInv(player, 14);
  106.    if(mana >= cost || GetInv(player, 14) >= GetInv(player, 69))
  107.    {
  108.       if(HasLOS(player, victim))             // check that we still have a LOS on it...
  109.       {
  110.          SetBinWait(player, 31, rank + 0.5);
  111.  
  112.          PlayMode(player, 24);
  113.          if(GetInv(player, 64) != 1) ChangeInv(player, 14, -cost);
  114.  
  115.          // Send a "force disturbance"...
  116.          if(!IsMulti())
  117.             SendMessageExRadius(GetThingPos(player), cost, 0x4, splash, 31, 0, 0, 0);
  118.  
  119.          rank = GetInv(player, 31);
  120.          limit = rank * 2;
  121.          starthealth = GetThingHealth(player);
  122.  
  123.          if(GetThingType(victim) == 10)
  124.          {
  125.             // Multiplayer enemies
  126.             if(!(GetThingFlags(victim) & 0x200))
  127.             {
  128.                retval = SkillTarget(victim, player, 31, rank);
  129.                SetPulse(0.1);
  130.                count = 0;
  131.                SetInvActivated(player, 31, 1);
  132.             }
  133.             else
  134.             {
  135.                Return;
  136.             }
  137.          }
  138.          else
  139.          {
  140.             damage = SkillTarget(victim, player, 31, 0);
  141.  
  142.             if(damage > 0.0)
  143.             {
  144.                // Play choke animation on the victim.
  145.                PlayMode(victim, 25);
  146.                SetPulse(0.1);
  147.                count = 0;
  148.                SetInvActivated(player, 31, 1);
  149.             }
  150.          }
  151.       }
  152.    }
  153.  
  154.    Return;
  155.  
  156. # ........................................................................................
  157.  
  158. pulse:
  159.    if(targetting == 1)
  160.    {
  161.  
  162.       targetCount = targetCount + 1;
  163.       if(targetCount == 2)
  164.       {
  165.          if(GetInv(player, 64) != 1) ChangeInv(player, 14, -targetCost);
  166.          targetCount = 0;
  167.       }
  168.  
  169.       // Check all things for our victim.
  170.       victim = -1;
  171.       maxDot = 0;
  172.  
  173.       // Search for all players and actors.
  174.       potential = FirstThingInView(player, 70, 4, 0x404);
  175.       while(potential != -1)
  176.       {
  177.          if(
  178.             HasLOS(player, potential) &&
  179.             (potential != player) &&
  180.             (VectorDist(GetThingPos(player), GetThingPos(potential)) <= 1) &&
  181.             !(GetThingFlags(potential) & 0x200) &&
  182.             !(GetActorFlags(potential) & 0x100) &&
  183.             !((jkGetFlags(potential) & 0x20) && !IsInvActivated(player, 23)) &&
  184.             (jkGetBubbleDistance(potential) > 1.0)
  185.            )
  186.          {
  187.             if(!BitTest(GetActorFlags(potential), 0x100))
  188.             {
  189.                dot = ThingViewDot(player, potential);
  190.                if(dot > maxDot)
  191.                {
  192.                   victim = potential;
  193.                   maxDot = dot;
  194.                }
  195.             }
  196.          }
  197.          potential = NextThingInView();
  198.       }
  199.  
  200.       // If we have a victim...
  201.       if(victim != -1)
  202.       {
  203.          jkSetTargetColors(6, 7, 8);
  204.          jkSetTarget(victim);
  205.       }
  206.       else
  207.       {
  208.          jkEndTarget();
  209.       }
  210.    }
  211.    // this is the real Grip pulse
  212.    else
  213.    {
  214.       if((count > limit) ||
  215.          (GetThingHealth(player) < starthealth) ||
  216.          (GetActorFlags(player) & 0x800) ||
  217.          (GetThingFlags(victim) & 0x200)
  218.         )
  219.       {
  220.          call stop_power;
  221.          Return;
  222.       }
  223.  
  224.       if(HasLOS(player, victim))
  225.       {
  226.          if(GetThingType(victim) == 10)      // OTHER PLAYER
  227.          {
  228.             // everything is done in the victim's KYLE.COG handler
  229.             if(!(GetThingFlags(victim) & 0x200))
  230.                retval = SkillTarget(victim, player, 31, rank);
  231.          }
  232.          else                                // ENEMY
  233.          {
  234.             DamageThing(victim, damage * rank / 2, 0x8, player);
  235.             // Force the victim to stay in place
  236.             SetActorFlags(victim, 0x40000);
  237.             // But prepare to free it again in 0.45 seconds
  238.             SetTimerEx(0.45, victim, GetThingSignature(victim), 0);
  239.          }
  240.  
  241.          PlaySoundThing(gripSound, victim, 1.0, -1, -1, 0x80);
  242.          count = count + 1;
  243.          SetPulse(0.5);
  244.       }
  245.       else
  246.       {
  247.          // break the power if LOS is lost
  248.          call stop_power;
  249.       }
  250.    }
  251.  
  252.    Return;
  253.  
  254. # ........................................................................................
  255.  
  256. timer:
  257.    // This checks that the thing ref is still assigned to the same thing
  258.    if(GetThingSignature(GetSenderId()) == GetParam(0))
  259.    {
  260.       ClearActorFlags(GetSenderId(), 0x40000);
  261.    }
  262.  
  263.    Return;
  264.  
  265. # ........................................................................................
  266.  
  267. selected:
  268.    jkPrintUNIString(player, 31);
  269.    Return;
  270.  
  271. # ........................................................................................
  272.  
  273. deselected:
  274.    call stop_power;
  275.  
  276.    Return;
  277.  
  278. # ........................................................................................
  279.  
  280. killed:
  281.    if(GetSenderRef() != player) Return;
  282.  
  283. newplayer:
  284.    call stop_power;
  285.  
  286.    Return;
  287.  
  288. # ........................................................................................
  289.  
  290. enterbubble:
  291.    inbubble = 1;
  292.    call stop_power;
  293.    Return;
  294.  
  295. # ........................................................................................
  296.  
  297. exitbubble:
  298.    inbubble = 0;
  299.    Return;
  300.  
  301. # ........................................................................................
  302.  
  303. user0:
  304.    call stop_power;
  305.    Return;
  306.  
  307. # ........................................................................................
  308.  
  309. stop_power:
  310.    SetPulse(0);
  311.    SetInvActivated(player, 31, 0);
  312.    targetting = 0;
  313.    victim = -1;
  314.    active = 0;
  315.    jkEndTarget();
  316.  
  317.    Return;
  318.  
  319. end
  320.  
  321.  
  322.